<script>
export default {
  name: "consult",
  data() {
    return {
      consult: ''
    }
  },
  methods: {
    clickconsult() {
      if (!uni.getStorageSync('user_id')) {
        uni.showToast({
          title: '请先登录',
          icon: 'none'
        })
        return
      }
      if (!this.consult) {
        uni.showToast({
          title: '请输入您的意见',
          icon: 'none'
        })
        return
      }
      this.$api.consult({
        user_id: uni.getStorageSync('user_id'),
        content: this.consult
      }).then(res => {
        uni.showToast({
          title: '提交成功',
          icon: 'none'
        })
        this.consult = ''
      }).catch(err => {
        console.log(err)
      })
    }
  }
}
</script>

<template>
  <view class="comment">
    <view class="comment-content">
      <view class="comment-content-title">意见反馈</view>
      <view class="comment-content-input">
        <textarea v-model="consult" placeholder="请输入您的意见" style="height: 200rpx; width: 100%;"></textarea>
      </view>
      <view class="comment-content-btn" @click="clickconsult">
        <button>提交</button>
      </view>
    </view>
  </view>
</template>

<style scoped lang="scss">
.comment {
  .comment-content {
    padding: 20rpx;
    .comment-content-title {
      font-size: 32rpx;
      color: #333;
    }
    .comment-content-input {
      margin-top: 20rpx;
      textarea {
        width: 100%;
        height: 200rpx;
        padding: 20rpx;
        border: 1px solid #ccc;
        border-radius: 10rpx;
      }
    }
    .comment-content-btn {
      margin-top: 20rpx;
      button {
        width: 100%;
        height: 80rpx;
        background-color: #ff4d4f;
        color: #fff;
        border: none;
        border-radius: 10rpx;
      }
    }
  }
}
</style>